package com.villaday.idf.adapter3;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.model2.ShippingAddressesEntity;
import com.villaday.idf.util.PhoneUtil;

public class AddressAdapter extends AbsRecyclerViewAdapter<ShippingAddressesEntity.BodyEntity> {

    View.OnClickListener onClickListener;

    public AddressAdapter(Context context, View.OnClickListener onClickListener) {
        super(context, R.layout.recycle_address);
        this.onClickListener = onClickListener;
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, ShippingAddressesEntity.BodyEntity d, int position) {
        holder.bindTextView(R.id.tv_a_name, d.getLinkman())
                .bindTextView(R.id.tv_a_phone, d.getOverlayMobile())
                .bindTextView(R.id.tv_a_address, d.getRegion() + d.getAddress())
                .setViewVisible(R.id.tv_a_normal, d.isPreferred() ? View.VISIBLE : View.GONE);
        View view = holder.getView(R.id.iv_c_retire);
        view.setTag(position);
        view.setOnClickListener(onClickListener);

        PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_a_phone),true);
    }
}
